<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
?>
<script type="text/javascript" language="javascript">
    var combothajaranStoresaldo = createStore(false, 'mcombothajaranStoresaldo',['id_th_ajaran','tahun_ajaran'],'<?php echo base_url(); ?>' + 'tahunajaran/get_rows_combo');
    var urlprintsaldo='';
    defineTabFormDynamis(
    {
        name:'MyTabDaftarSaldoPiutangSiswa',
        xtype:'TabDaftarSaldoPiutangSiswa',
        alias:'widget.TabDaftarSaldoPiutangSiswa',
        title:'Daftar Saldo Piutang Siswa',
        id:'tab16'
        ,items:[           
            {
                
                xtype: 'panel',
                autoShow: true,
                autoScroll: true,
                enableToggle: true,
                title:'Print Preview PDF',
                id: 'panelsaldo_c',
                region: 'center',
                margins: '5 5 5 5',
                layout: 'fit',                
                tools: [{
                        type: 'maximize',
                        tooltip: 'Maximize Print Preview' 
                        ,listeners:{
                            click:function()   {
                                var urlprint='';
                               
                                                                    if(!urlprintsaldo){
                                                                        set_message(1, 'Parameter Pilihan Belum Tidak Valid !!!');
                                                                        return;
                                                                    }
                               
                                var winprintsaldo=Ext.create('winprint2');
                                winprintsaldo.maximize();
                                to_print('printoutpdf2', urlprintsaldo);                         
                            }
                        }
                    }],
                html:'<iframe style="width:100%;height:100%;" id="printsaldo" src=""></iframe>'
                ,tbar:[{
                        xtype: 'button',
                        id:'saldo_cetak',
                        text: 'Tampilkan',
                        iconCls: 'icon-preview_report',
                        enableToggle: true,
                        onClick: function(btn){
                            getComp('saldo_cetak').toggle(false);   
                            getComp('saldo_rekap').toggle(false);   
                            var urlprint='base_report/saldopiutang_print?idthajaran=';
                                
        
                            urlprintsaldo='';
                            var winsaldopiutang=Ext.create('winthnisthbl');
                            
                            winsaldopiutang.on('close',function(){                                
                                if(!urlprintsaldo){
                                    getComp('saldo_cetak').toggle(false);   
                                    getComp('saldo_rekap').toggle(false);   
                                }
                            });
                            
                            var nis='';
                            var idthajaran='';
                            var thajaran='';
                            var thbl='';
                            var kelas='';
                            var semester='';
                            var idsemester='';
                            getComp('btn_tnt_proses_id').on('click',function(){
                                
                                urlprint='base_report/saldopiutang_print?idthajaran=';
                                idthajaran=getComp('tnt_id_th_ajaran').getValue();
                                nis=getComp('tnt_nis').getValue();
                                kelas=getComp('tnt_kd_kelas').getValue();
                                
                                idsemester=getComp('tnt_semester').getValue();
                                if(!idthajaran){
                                    set_message(1, 'Tahun Ajaran Tidak Valid!!');
                                    return;
                                }else{
                                  thajaran=  getComp('tnt_id_th_ajaran').getRawValue();
                                  urlprint += idthajaran + '&thajaran=' + thajaran;
                                  if(idsemester){
                                      urlprint += '&idsemester=' + idsemester;
                                      semester=getComp('tnt_semester').getRawValue();
                                      urlprint += '&semester=' + semester;
                                  }
                                  
                                }
                                
                                if(getComp('tnt_tahun').getValue() && getComp('tnt_bulan').getValue()){
                                    thbl=setThbl(Ext.getCmp('tnt_tahun').getValue(), Ext.getCmp('tnt_bulan').getValue());;
                                    urlprint += '&thbl=' + thbl;
                                }     
                                if(kelas){
                                    urlprint += '&kelas=' + kelas;
                                }
                                
                                if(nis){
                                    urlprint += '&nis=' + nis;
                                }
                                urlprintsaldo=urlprint;
                                to_print('printsaldo', urlprintsaldo);
                                getComp('saldo_cetak').toggle();
                                getComp('winthnisthbl_id').close();
                            });
                            winsaldopiutang.show();
                            
                            //                            getComp('btn_cetakpotongan').toggle(false);
                            //                            to_print('printdbs', urlprint);
                        }
                    }
                    ,{
                        xtype: 'button',
                        id:'saldo_rekap',
                        text: 'Rekap',
                        iconCls: 'icon-preview_report',
                        enableToggle: true,
                        onClick: function(btn){
                            var urlprint='base_report/saldopiutangrekap_print';
                            getComp('saldo_cetak').toggle(false);   
                                    getComp('saldo_rekap').toggle(false);   
        
                            urlprintsaldo='';
//                            var winnisth=getComp('winthnisthbl');
                            
                            var winsaldopiutang2=Ext.create('winnis');
                            getComp('base_kd_kelas').setVisible(false);
                            winsaldopiutang2.on('close',function(){                                
                                if(!urlprintsaldo){
                                    getComp('saldo_cetak').toggle(false);   
                                    getComp('saldo_rekap').toggle(false);   
                                }
                            });
                            getComp('btn_base_proses_id').on('click',function(){
                                if(getComp('base_nis').getValue()){                                   
                                    var nis=getComp('base_nis').getValue();                                    
                                    urlprint += '?nis=' + nis;
                                    urlprintsaldo=urlprint;
                                    to_print('printsaldo', urlprintsaldo);
                                    getComp('saldo_rekap').toggle();   
                                    getComp('winnis_id').close();
                                }else{
                                    urlprintsaldo=urlprint;
                                    to_print('printsaldo', urlprintsaldo);
                                    getComp('saldo_rekap').toggle();   
                                    getComp('winnis_id').close();
                                }
                                
                            });
                            winsaldopiutang2.show();
                        }
                    }
                    ]
                
            }
        ]
            
    },
    function(){
    }
);
</script>


